package br.com.center.loja.mb;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.model.SelectItem;

import br.com.center.loja.mb.utils.BrazilState;
import br.com.center.loja.model.City;
import br.com.center.loja.model.TypeCity;

@ManagedBean(name="city")
@ViewScoped
public class CityMB extends AbstractMB<City> {

	private static final long serialVersionUID = 1L;
	
	public CityMB() {
		super(City.class);
	}
	
	public SelectItem[] getStateItems(){
		BrazilState[] states = BrazilState.values();
		SelectItem[] items = new SelectItem[states.length];
		int position = 0;
		
		for (BrazilState state : states) {
			items[position++] = new SelectItem(state.name(), state.getName());
		}
		
		return items;
	}

	public SelectItem[] getTypeCityItems(){
		TypeCity[] types = TypeCity.values();
		SelectItem[] items = new SelectItem[types.length];
		int position = 0;
		
		for (TypeCity type : types) {
			items[position++] = new SelectItem(type, type.getDescription());
		}
		
		return items;
	}
}
